package yto.freemarker.springaop.app;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import yto.freemarker.springaop.service.IndexService;
import yto.freemarker.springaop.service.UserService;

/**
 * @author dongxing
 **/
@Configuration  //实现代理
@ComponentScan("yto.freemarker.springaop")
public class AppConfig{


    /**
     * 1、如果方法是静态的话，还是会初始化2次
     * 2、如果不加@Configuration 也会加载2次
     * @return
     */
    @Bean
    public IndexService indexService() {
        return new IndexService();
    }

    @Bean
    public UserService userService() {
        indexService();
        return new UserService();
    }

}
